package com.mofang.ticketing.base.serve.file.task;


import com.mofang.ticketing.base.serve.file.service.IAttachmentManageService;
import com.mofang.ticketing.common.redis.distributedLock.RedissonLocker;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author LGC
 * @date 2021/8/3 14:11
 * @copyright 2021 mofang. All rights reserved
 */
@Component
@EnableScheduling
@EnableAsync
public class AttachmentTask {
    @Resource
    private IAttachmentManageService attachmentManageService;

    @Resource
    private RedissonLocker redissonLocker;

//    /**
//     * 每天执行1点执行
//     * 定时删除 当前时间前7天所有附件
//     */
//    @Scheduled(cron = "${time.cron.delAttachment}")
//    public void execute() throws Throwable {
//        redissonLocker.lock("delAttachment", () -> {
//            final Calendar c = Calendar.getInstance();
//            if (c.get(Calendar.DATE) == c.getActualMaximum(Calendar.DATE)) {
//                attachmentManageService.delAttachment(7);
//            }
//            return null;
//        });
//
//
//    }


}
